package view;

import controller.AccountController;
import util.MenuInputUtil;

/**
 * 显示类
 */
public class Main {

    public void mainMenu(){
        System.out.println("+---------- 账号记忆工具 ----------+");
        System.out.println("        1. 按关键字查询");
        System.out.println("        2. 查询所有已保存的账户");
        System.out.println("        3. 保存新账户");
        System.out.println("        4. 修改指定账户");
        System.out.println("        5. 删除指定账户");
        System.out.println("        6. 退出程序");
        System.out.println("+--------------------------------+");
        System.out.print("> ");
    }

    public void start(){
        while(true) {
            //显示主菜单
            mainMenu();
            //输入选项序号
            int option = MenuInputUtil.readMenuSelection(1, 6);
            //是否退出程序
            if(option == 6){
                return;
            }
            //执行指定选项功能
            AccountController controller = new AccountController();
            controller.operate(option);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        new Main().start();
    }
}
